﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Qplus.UI
{
    public partial class SearchControl : UserControl
    {
        string userName;
        string age;
        int sex;
        int pageNum;
        public SearchControl()
        {
            InitializeComponent();
        }

        public string UserName { get { return userName; } set { userName = value; } }
        public string Age { get { return age; } set { age = value; } }
        public int Sex { get { return sex; } set { sex = value; } }
        public int PageNum { get { return pageNum; } set { pageNum = value; } }
        private void maleBtn_Click(object sender, RoutedEventArgs e)
        {
            if (maleRbtn.IsChecked == false)
            {
                maleRbtn.IsChecked = true;
            }
        }

        private void femaleBtn_Click(object sender, RoutedEventArgs e)
        {
            if (femaleRbtn.IsChecked == false)
            {
                femaleRbtn.IsChecked = true;
            }
        }

        private void unknowBtn_Click(object sender, RoutedEventArgs e)
        {
            if (unknowRbtn.IsChecked == false)
            {
                unknowRbtn.IsChecked = true;
            }
        }

        private void maleRbtn_Checked(object sender, RoutedEventArgs e)
        {
            this.Sex = 1;
            maleImgSelect.Visibility = System.Windows.Visibility.Visible;
            maleImgUnSelect.Visibility = System.Windows.Visibility.Collapsed;
            maleTxtBlk.Foreground = new SolidColorBrush(Colors.Blue);
        }

        private void maleRbtn_Unchecked(object sender, RoutedEventArgs e)
        {
            maleImgSelect.Visibility = System.Windows.Visibility.Collapsed;
            maleImgUnSelect.Visibility = System.Windows.Visibility.Visible;
            maleTxtBlk.Foreground = new SolidColorBrush(Colors.White);
        }

        private void femaleRbtn_Checked(object sender, RoutedEventArgs e)
        {
            this.Sex = 2;
            femaleImgSelect.Visibility = System.Windows.Visibility.Visible;
            femaleImgUnSelect.Visibility = System.Windows.Visibility.Collapsed;
            femaleTxtBlk.Foreground = new SolidColorBrush(Colors.Red);
        }

        private void femaleRbtn_Unchecked(object sender, RoutedEventArgs e)
        {
            femaleImgSelect.Visibility = System.Windows.Visibility.Collapsed;
            femaleImgUnSelect.Visibility = System.Windows.Visibility.Visible;
            femaleTxtBlk.Foreground = new SolidColorBrush(Colors.White);
        }

        private void unknowRbtn_Checked(object sender, RoutedEventArgs e)
        {
            this.Sex = 0;
            unknowImgSelect.Visibility = System.Windows.Visibility.Visible;
            unknowImgUnSelect.Visibility = System.Windows.Visibility.Collapsed;
            unknowTxtBlk.Foreground = new SolidColorBrush(Colors.Green);
        }

        private void unknowRbtn_Unchecked(object sender, RoutedEventArgs e)
        {
            unknowImgSelect.Visibility = System.Windows.Visibility.Collapsed;
            unknowImgUnSelect.Visibility = System.Windows.Visibility.Visible;
            unknowTxtBlk.Foreground = new SolidColorBrush(Colors.White);
        }

        private void ButtonEx_Click(object sender, RoutedEventArgs e)
        {
            string test = "Oc";
            string test2 = "";
            int test3 = 1;
            int test4 = 0;

            UIData.getInstance().SearchFriend(test, test2, test3, test4);

            //Commands.SearchFriendCommand command_SearchFriend = new Commands.SearchFriendCommand(
            //    UIData.getInstance().L2C.UserID, UIData.getInstance().L2C.Key);
            //command_SearchFriend.set(test, test2, test3, test4);
            //command_SearchFriend.execute(UIData.getInstance().L2C.UpgradeURL);

            this.Visibility = System.Windows.Visibility.Collapsed;
        }

        private void nickName_TextChanged(object sender, TextChangedEventArgs e)
        {
            UserName = nickName.Text;
        }

        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton rbtn = sender as RadioButton;
            Age = rbtn.Content.ToString();
        }
    }
}
